﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Sahit.iSoilHotel.RESTfulDistributedServices.MainBoundedContext.Interfaces;
using Sahit.iSoilHotel.Application.MainBoundedContext.DTO;
using Sahit.iSoilHotel.Application.MainBoundedContext.Tavern.Interfaces;
using Sahit.iSoilHotel.RESTfulDistributedServices.MainBoundedContext.InstanceProviders;

namespace Sahit.iSoilHotel.RESTfulDistributedService.MainBoundedContext
{
    // Start the service and browse to http://<machine_name>:<port>/Service1/help to view the service's generated help page
    // NOTE: By default, a new instance of the service is created for each call; change the InstanceContextMode to Single if you want
    // a single instance of the service to process all calls.	
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [UnityInstanceProviderServiceBehavior()]
    // NOTE: If the service is renamed, remember to update the global.asax.cs file
    public class TavernService : ITavernService
    {
        //// TODO: Implement the collection resource that will contain the SampleItem instances

        //[WebGet(UriTemplate = "")]
        //public List<SampleItem> GetCollection()
        //{
        //    // TODO: Replace the current implementation to return a collection of SampleItem instances
        //    return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Hello" } };
        //}

        //[WebInvoke(UriTemplate = "", Method = "POST")]
        //public SampleItem Create(SampleItem instance)
        //{
        //    // TODO: Add the new instance of SampleItem to the collection
        //    throw new NotImplementedException();
        //}

        //[WebGet(UriTemplate = "{id}")]
        //public SampleItem Get(string id)
        //{
        //    // TODO: Return the instance of SampleItem with the given id
        //    throw new NotImplementedException();
        //}

        //[WebInvoke(UriTemplate = "{id}", Method = "PUT")]
        //public SampleItem Update(string id, SampleItem instance)
        //{
        //    // TODO: Update the given instance of SampleItem in the collection
        //    throw new NotImplementedException();
        //}

        //[WebInvoke(UriTemplate = "{id}", Method = "DELETE")]
        //public void Delete(string id)
        //{
        //    // TODO: Remove the instance of SampleItem with the given id from the collection
        //    throw new NotImplementedException();
        //}

        #region Members

        private readonly IAccountService accountService;

        #endregion

        #region Constructor

        public TavernService(IAccountService accountService)
        {
            if (accountService == null)
                throw new ArgumentNullException("AccountService");

            this.accountService = accountService;
        }

        #endregion

        #region ITavernService Methods

        public AccountDTO Login(string userName, string password)
        {
            return accountService.Login(userName, password);
        }

        #endregion
    }
}
